﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Configuration;

namespace SmartParking.Bussiness
{
    public static class SmartParkingSettings
    {
        public static bool Logger
        {
            get
            {
                return AppSettings.Setting<bool>("SmartParking:Logger");
            }
        }

        public static decimal TipoCambio
        {
            get
            {
                return AppSettings.Setting<decimal>("SmartParking:TipoCambio");
            }
        }
    }

    public static class AppSettings
    {
        public static T Setting<T>(string name)
        {
            string value = ConfigurationManager.AppSettings[name];
            if (value == null)
            {
                return default(T);
            }
            return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
        }
    }
}
